package com.distortiongames.level27.generation.random
{
	
	/**
	 * ...
	 * @author Jefferson Wagner
	 */
	public class ChanceWithMinimum extends Chance
	{
		private var minimumRolls:int, currentRolls:int;
		
		public function ChanceWithMinimum(baseChance:Number=  0, chanceIncrease:Number= 0, minimumRolls:int = 0)
		{
			super(baseChance, chanceIncrease);
			this.minimumRolls = minimumRolls;
			currentRolls = 0;
		}
		
		public function copyMinimum() : ChanceWithMinimum {
			return new ChanceWithMinimum(baseChance, chanceIncrease, minimumRolls);
		}
		
		override public function roll():Boolean
		{
			var success:Boolean = false;
			if (currentRolls >= minimumRolls)
			{
				success = super.roll();
				if (success)
					currentRolls = 0;
			}
			currentRolls++;
			return success;
		}
		
		public function getMinimumRolls():int
		{
			return minimumRolls;
		}
		
		public function setMinimumRolls(minimumRolls:int):void
		{
			this.minimumRolls = minimumRolls;
		}
		
		public override function reset():void
		{
			super.reset();
			currentRolls = 0;
		}
	
	}

}